function [file,heating,coeff,coeff_err,datatype,scandirection,conditions,RFdBm,z] = import_summary(workbookFile,sheetName,startRow,endRow)
%IMPORTFILE Import data from a spreadsheet
%   [file,heating,coeff,datatype,scandirection,conditions,RFdBm,z] =
%   IMPORTFILE(FILE) reads data from the first worksheet in the Microsoft
%   Excel spreadsheet file named FILE and returns the data as column
%   vectors.
%
%   [file,heating,coeff,datatype,scandirection,conditions,RFdBm,z] =
%   IMPORTFILE(FILE,SHEET) reads from the specified worksheet.
%
%   [file,heating,coeff,datatype,scandirection,conditions,RFdBm,z] =
%   IMPORTFILE(FILE,SHEET,STARTROW,ENDROW) reads from the specified
%   worksheet for the specified row interval(s). Specify STARTROW and
%   ENDROW as a pair of scalars or vectors of matching size for
%   dis-contiguous row intervals. To read to the end of the file specify an
%   ENDROW of inf.%
% Example:
%   [file,heating,coeff,datatype,scandirection,conditions,RFdBm,z] = importfile('heatscangrad_summary.xlsx','Sheet1',2,12);
%
%   See also XLSREAD.

% Auto-generated by MATLAB on 2017/11/28 14:27:02

%% Input handling

% If no sheet is specified, read first sheet
if nargin == 1 || isempty(sheetName)
    sheetName = 1;
end

% If row start and end points are not specified, define defaults
if nargin <= 3
    startRow = 2;
    endRow = 13;
end

%% Import the data
[~, ~, raw] = xlsread(workbookFile, sheetName, sprintf('A%d:J%d',startRow(1),endRow(1)));
for block=2:length(startRow)
    [~, ~, tmpRawBlock] = xlsread(workbookFile, sheetName, sprintf('A%d:J%d',startRow(block),endRow(block)));
    raw = [raw;tmpRawBlock]; %#ok<AGROW>
end
raw(cellfun(@(x) ~isempty(x) && isnumeric(x) && isnan(x),raw)) = {''};
cellVectors = raw(:,[1,5,6,7,10]);
raw = raw(:,[2,3,4,8,9]);

%% Create output variable
I = cellfun(@(x) ischar(x), raw);
raw(I) = {NaN};
data = reshape([raw{:}],size(raw));

%% Allocate imported array to column variable names
file = cellVectors(:,1);
heating = data(:,1);
coeff = data(:,2);
coeff_err = data(:,3);
datatype = cellVectors(:,2);
scandirection = cellVectors(:,3);
conditions = cellVectors(:,4);
RFdBm = data(:,4);
z = data(:,5);

